var defaults = {
    deVal: 0, //传入值
    className: 'dataNums', //样式名称
    digit: 6, //默认显示几位数字,
    classNameEx: 'dataOne',
    tt: 'tt'
};

function rollNumDaq(obj, options) {
    this.obj = obj;
    this.options = $.extend(defaults, options);
    this.init = function () {
        this.initHtml(obj, defaults);
    }
}
rollNumDaq.prototype = {
    initHtml: function (obj, options) {
        var strHtml = '<ul class="' + options.className + ' inrow">';
        var valLen = options.digit || (options.deVal + '').length;
        if (obj.find('.' + options.className).length <= 0) {
            for (var i = 0; i < valLen; i++) {
                strHtml
                    += '<li class="' + defaults.classNameEx + ' "><div class="dataBoc"><div class="' +
                    options.tt +
                    '" t="38"><span class="num0">0</span> <span class="num1">1</span> <span class="num2">2</span> <span class="num3">3</span> <span class="num4">4</span><span class="num5">5</span> <span class="num6">6</span> <span class="num7">7</span> <span class="num8">8</span> <span class="num9">9</span><span class="num0">0</span> <span class="num1">1</span> <span class="num2">2</span> <span class="num3">3</span> <span class="num4">4</span><span class="num5">5</span> <span class="num6">6</span> <span class="num7">7</span> <span class="num8">8</span> <span class="num9">9</span></div></div></li>';
            }
            strHtml += '</ul>';
            obj.html(strHtml);
        }
        this.scroNum(options, obj);
    },
    scroNum: function (options,
        obj) {
        var number = options.deVal;
        var $num_item = $(obj).find('.' + options.tt);
        var
            h = $('.dataBoc').height();
        $num_item.css('transition', 'all 2s ease-in-out');
        var
            numberStr = number.toString();
        if (numberStr.length <= $num_item.length - 1) {
            var tempStr = '';
            for (var
                    a = 0; a < $num_item.length - numberStr.length; a++) {
                tempStr += '0';
            }
            numberStr = tempStr + numberStr;
        }
        var numberArr = numberStr.split('');
        $num_item.each(function (i, item) {
            setTimeout(function () {
                $num_item.eq(i).css('top', -parseInt(numberArr[i]) * h - h * 10 + 'px');
            }, i * 10)
        });
    }
}
// $.fn.rollNumDaq = function (options) {
//     alert(123)
//     var $that = this;
//     var rollNumObj = new rollNumDaq($that, options);
//     rollNumDaq
//     rollNumObj.init();
// };

function loadData(options) {
    var opt = $.extend(true, {
        container: {
            containerYD: null,
            containerSD: null,
            containerQY: null,
            containerKQL: {
                containerKQL1: null,
                containerKQL2: null
            }
        },
        dispatchType: "",
        detailType: "",
        city: '',
        classNameEx: {
            className1: "dataOne",
            className2: "dataTwo",
            className3: "datatthree"
        }
    }, options);
    // p.post("/Service/EmployeeInfoWebSvr.assx/GetStaticAttendanceNum", {
    //     date: escape($("#txtDate").datebox("getValue")),
    //     dispatchType: escape(opt.dispatchType),
    //     city: escape(city)
    // }, function (data) {
    // 模拟数据
    var data = {
        City: null,
        KqRates: 97.7,
        QqCounts: 3,
        SdCounts: 134,
        Times: null,
        Type: null,
        YdCounts: 143
    };
    if (data) {
        if (opt.container.containerYD) {
            $("#" + opt.container.containerYD).html(data.YdCounts);
        }

        if (opt.container.containerSD) {
            $("#" + opt.container.containerSD).empty();
            $("#" + opt.container.containerSD).rollNumDaq({
                deVal: data.SdCounts,
                digit: (data.SdCounts + '').length,
                classNameEx: opt.classNameEx.className1
            });
        }

        if (opt.container.containerQY) {
            $("#" + opt.container.containerQY).empty();
            $("#" + opt.container.containerQY).rollNumDaq({
                deVal: data.QqCounts,
                digit: (data.QqCounts + '').length,
                classNameEx: opt.classNameEx.className2
            });
        }

        if (opt.container.containerKQL) {
            var numiint = 0;
            var numfloat = 0;

            datenum = data.KqRates.toString();
            if (datenum.indexOf(".") == -1) {
                numint = datenum;
                numfloat = 0;
            } else {
                numint = datenum.substring(0, datenum.indexOf("."));
                numfloat = datenum.substring(datenum.indexOf(".") + 1, (datenum + '').length);
                if (numfloat.length == 1) {
                    numfloat = numfloat + "0";
                }
            }

            if (opt.container.containerKQL.containerKQL1) {
                $("#" + opt.container.containerKQL.containerKQL1).empty();
                $("#" + opt.container.containerKQL.containerKQL1).rollNumDaq({
                    deVal: numint,
                    classNameEx: opt.classNameEx.className3,
                    digit: 2
                });
            }

            if (opt.container.containerKQL.containerKQL2) {
                $("#" + opt.container.containerKQL.containerKQL2).empty();
                $("#" + opt.container.containerKQL.containerKQL2).rollNumDaq({
                    deVal: numfloat,
                    classNameEx: opt.classNameEx.className3,
                    digit: 2
                });
            }
        }
    }
    // });
}
// Reload();

function Reload() {
    loadData({
        container: {
            containerSD: "dataNumsSdjl",
            containerQY: "dataNumsQqjl",
            containerYD: "spnumydjl",
            containerKQL: {
                containerKQL1: "dataNumsKqljl_1",
                containerKQL2: "dataNumsKqljl_2"
            }
        },
        dispatchType: "项目经理",
        detailType: "JobPersonXMJL"
    });
    loadData({
        container: {
            containerSD: "dataNumsSdzj",
            containerQY: "dataNumsQqzj",
            containerYD: "spnumydzj",
            containerKQL: {
                containerKQL1: "dataNumsKqlzj_1",
                containerKQL2: "dataNumsKqlzj_2"
            }
        },
        dispatchType: "项目总监",
        detailType: "JobPersonZJLGCS"
    });
    loadData({
        container: {
            containerSD: "dataNumsSdqt",
            containerQY: "dataNumsQqqt",
            containerYD: "spnumydqt",
            containerKQL: {
                containerKQL1: "dataNumsKqlqt_1",
                containerKQL2: "dataNumsKqlqt_2"
            }
        },
        dispatchType: "其他岗位人员",
        detailType: "JobPersonQTGWRY"
    });
    loadData({
        container: {
            containerSD: "dataNumsSdlw",
            containerYD: "spnumydlw"
        },
        dispatchType: "劳务人员",
        detailType: "JobPersonNWRY"
    });
}

//JavaScript代码区域
$('#time_text').text(getNowDate());

function getNowDate() {
    var now = new Date();
    if (parseInt(now.getDate()) < 10) {
        var getDate = '0' + now.getDate();
    } else {
        var getDate = now.getDate();
    }
    if (parseInt(now.getMonth() + 1) < 10) {
        var getMouth = '0' + parseInt(now.getMonth() + 1);
    } else {
        var getMouth = parseInt(now.getMonth() + 1);
    }
    return now.getFullYear() + '-' + getMouth +
        '-' + getDate;
}




// table

function attanceTable() {
    // 1
    $('#table_a').bootstrapTable({
        columns: [{
            field: 'number',
            title: '序号',
            formatter: function (value, row, index) {

                return index + 1;
            }
        }, {
            field: 'workname',
            title: '岗位名称 '

        }, {
            field: 'name',
            title: '姓名 '
        }, {
            field: 'IDnumber',
            title: '身份证号 '
        }, {
            field: 'major',
            title: '专业 '
        }, {
            field: 'certificate',
            title: '任职资格及证书编号'
        }, {
            field: 'tel',
            title: '联系电话'
        }, {
            field: 'judgement',
            title: '是否持证上岗 '
        }],
        data: [{
            number: '',
            workname: '安全员',
            name: '陈东东',
            IDnumber: '622826199308201550',
            major: '-',
            certificate: '',
            tel: '-',
            judgement: '否'
        }, {
            number: '',
            workname: '其他',
            name: '莫泽锐',
            IDnumber: '460002198508095210',
            major: '-',
            certificate: '',
            tel: '-',
            judgement: '否'
        }, {
            number: '',
            workname: '安全员',
            name: '梁贵学',
            IDnumber: '522324197012041217',
            major: '-',
            certificate: '',
            tel: '-',
            judgement: '否'
        }, {
            number: '',
            workname: '安全员',
            name: '蒋宏辉',
            IDnumber: '452323196903142530',
            major: '-',
            certificate: '',
            tel: '-',
            judgement: '否'
        }]
    });
    $('#table_b').bootstrapTable({
        columns: [{
            field: 'number',
            title: '序号',
            formatter: function (value, row, index) {

                return index + 1;
            }
        }, {
            field: 'name',
            title: '姓名 '
        }, {
            field: 'tel',
            title: '手机号码'
        }, {
            field: 'money',
            title: '工资 '
        }, {
            field: 'type',
            title: '工种'
        }, {
            field: 'word',
            title: '劳动合同编号'
        }, {
            field: 'wordnumber',
            title: '劳动合同编号扫描件',
            formatter: function (value, row, index) {

            }
        }],
        data: [{
            number: '',
            name: '黄祥华',
            tel: '-',
            money: '-',
            type: '',
            word: '-',
            wordnumber: '查看 '
        }, {
            number: '',
            name: '陈庆',
            tel: '-',
            money: '-',
            type: '',
            word: '-',
            wordnumber: '查看 '
        }, {
            number: '',
            name: '石勇',
            tel: '-',
            money: '-',
            type: '',
            word: '-',
            wordnumber: '查看 '
        }, {
            number: '',
            name: '李刚学',
            tel: '-',
            money: '-',
            type: '',
            word: '-',
            wordnumber: '查看 '
        }]
    });
    $('#table_d').bootstrapTable({
        columns: [{
            field: 'number',
            title: '序号',
            formatter: function (value, row, index) {

                return index + 1;
            }
        }, {
            field: 'time',
            title: '考勤日期'
        }, {
            field: 'type',
            title: '人员类型'
        }, {
            field: 'name',
            title: '姓名 '
        }, {
            field: 'male',
            title: '性别'
        }, {
            field: 'IDnumber',
            title: '身份证号'
        }, {
            field: 'tel',
            title: '手机号码',
        }, {
            field: 'judgement',
            title: '是否持证上岗',
        }, {
            field: 'early',
            title: '最早进场时间',
        }, {
            field: 'late',
            title: '最晚离场时间',
        }, {
            field: 'operate',
            title: '操作',
        }],
        data: [{
            number: '',
            time: '2019-12-14',
            type: '-',
            name: '王伟伟',
            male: '男',
            IDnumber: '430426198808208755',
            tel: '',
            judgement: '否',
            early: '2019-12-14 08:31:52',
            late: '2019-12-13 10:19:48',
            operate: '查看'
        }, {
            number: '',
            time: '2019-12-14',
            type: '-',
            name: '王伟伟',
            male: '男',
            IDnumber: '430426198808208755',
            tel: '',
            judgement: '否',
            early: '2019-12-14 08:31:52',
            late: '2019-12-13 10:19:48',
            operate: '查看'
        }, {
            number: '',
            time: '2019-12-14',
            type: '-',
            name: '唐云宣',
            male: '男',
            IDnumber: '513023196810186156',
            tel: '',
            judgement: '否',
            early: '2019-12-14 08:31:52',
            late: '2019-12-13 10:19:48',
            operate: '查看'
        }, {
            number: '',
            time: '2019-12-14',
            type: '-',
            name: '王武',
            male: '男',
            IDnumber: '430624199203117933',
            tel: '',
            judgement: '否',
            early: '2019-12-14 08:31:52',
            late: '2019-12-13 10:19:48',
            operate: '查看'
        }]
    });
    $('#table_e').bootstrapTable({
        columns: [{
            field: 'number',
            title: '序号',
            formatter: function (value, row, index) {

                return index + 1;
            }
        }, {
            field: 'time',
            title: '考勤日期'
        }, {
            field: 'name',
            title: '姓名 '
        }, {
            field: 'tel',
            title: '手机号码',
        }, {
            field: 'worktype',
            title: '工种',
        }, {
            field: 'workin',
            title: '所在班组',
        }, {
            field: 'early',
            title: '最早进场时间',
        }, {
            field: 'late',
            title: '最晚离场时间',
        }, {
            field: 'operate',
            title: '操作',
        }],
        data: [{
            number: '',
            time: '2019-12-14',
            name: '王伟伟',
            tel: '',
            worktype: '',
            workin: '',
            early: '2019-12-14 08:31:52',
            late: '2019-12-13 10:19:48',
            operate: '查看'
        }, {
            number: '',
            time: '2019-12-14',
            name: '王伟伟',
            tel: '',
            worktype: '',
            workin: '',
            early: '2019-12-14 08:31:52',
            late: '2019-12-13 10:19:48',
            operate: '查看'
        }, {
            number: '',
            time: '2019-12-14',
            name: '唐云宣',
            tel: '',
            worktype: '',
            workin: '',
            early: '2019-12-14 08:31:52',
            late: '2019-12-13 10:19:48',
            operate: '查看'
        }, {
            number: '',
            time: '2019-12-14',
            name: '王武',
            tel: '',
            worktype: '',
            workin: '',
            early: '2019-12-14 08:31:52',
            late: '2019-12-13 10:19:48',
            operate: '查看'
        }]
    });
    $('#table_f').bootstrapTable({
        columns: [{
            field: 'number',
            title: '序号',
            formatter: function (value, row, index) {

                return index + 1;
            }
        }, {
            field: 'projectname',
            title: '工程名称'
        }, {
            field: 'equipmentnumber',
            title: '设备编号 '
        }, {
            field: 'type',
            title: '设备类型',
        }, {
            field: 'rights',
            title: '产权单位',
        }, {
            field: 'workintime',
            title: '入库日期',
        }, {
            field: 'equipment',
            title: '设备厂家',
        }, {
            field: 'usestatus',
            title: '使用设备状态',
        }, {
            field: 'status',
            title: '考勤设备在线状态',
        }, {
            field: 'operate',
            title: '操作',
        }],
        data: [{
            number: '',
            projectname: '海南清水湾B11-1、B11-2区2栋公寓、4栋高层及地下车库工程(海南清水湾B11-1、B11-2区2栋公寓、4栋高层及地下车库工程)',
            equipmentnumber: '84:e0:f4:20:88:9c',
            type: '进场设备',
            rights: '广州振中建设有限公司',
            workintime: '2019-06-27',
            equipment: '海南方胜科学仪器有限公司',
            usestatus: '使用中',
            status: '离线',
            operate: '使用记录 '
        }, {
            number: '',
            projectname: '海南清水湾B11-1、B11-2区2栋公寓、4栋高层及地下车库工程(海南清水湾B11-1、B11-2区2栋公寓、4栋高层及地下车库工程)',
            equipmentnumber: '1014432914-I',
            type: '进场设备',
            rights: '广州振中建设有限公司',
            workintime: '2019-06-07',
            equipment: '无锡微天下网络科技有限公司',
            usestatus: '使用中',
            status: '离线',
            operate: '使用记录 '
        }, {
            number: '',
            projectname: '海南清水湾B11-1、B11-2区2栋公寓、4栋高层及地下车库工程(海南清水湾B11-1、B11-2区2栋公寓、4栋高层及地下车库工程)',
            equipmentnumber: '1014432914-O',
            type: '进场设备',
            rights: '广州振中建设有限公司',
            workintime: '2019-06-07',
            equipment: '无锡微天下网络科技有限公司',
            usestatus: '使用中',
            status: '离线',
            operate: '使用记录 '
        }, {
            number: '',
            projectname: '海南清水湾B11-1、B11-2区2栋公寓、4栋高层及地下车库工程(海南清水湾B11-1、B11-2区2栋公寓、4栋高层及地下车库工程)',
            equipmentnumber: 'F600BX1904100107',
            type: '采集设备',
            rights: '广州振中建设有限公司',
            workintime: '2019-06-07',
            equipment: '无锡微天下网络科技有限公司',
            usestatus: '使用中',
            status: '离线',
            operate: '使用记录 '
        }, {
            number: '',
            projectname: '海南清水湾B11-1、B11-2区2栋公寓、4栋高层及地下车库工程(海南清水湾B11-1、B11-2区2栋公寓、4栋高层及地下车库工程)',
            equipmentnumber: 'WFR01-01019',
            type: '出场设备',
            rights: '广州振中建设有限公司',
            workintime: '2019-06-07',
            equipment: '海南汇高电子科技有限公司',
            usestatus: '使用中',
            status: '在线',
            operate: '使用记录 '
        }]
    })
}